﻿@{
    Bundle("jquery_validate");
}

<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('@ID("#form")').validate({
            rules: {
                email: {
                    required: true,
                    email: true
                },
                username: {
                    required: true,
                    regex: '@Svc.Config(Par.In("Core").Of("AccountEntity").Name("UsernamePattern"))'
                }
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("Profile").Area("Globalization"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_profile")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
                ddl.val('@JDM.Int32(Model.LocalizationProfile.EntityID)');
            }
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Update").Ctrl("Account"))" method="post">
    <input type="hidden" name="flags" value="None" />
    <table>
        <tr>
            <td>
                <label>#</label>
            </td>
            <td>
                <input type="text" readonly name="id" value="@JDM.Int32(Model.EntityID)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10001;</label>
            </td>
            <td>
                <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.CreatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10002;</label>
            </td>
            <td>
                <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.UpdatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Guid"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Guid(Model.Guid)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("LocalizationProfile"))</label>
            </td>
            <td>
                <select id="@ID("ddl_profile")" name="localizationProfileID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Email"))</label>
            </td>
            <td>
                <input type="text" name="email" value="@JDM.String(Model.Email)" maxlength="100" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Username"))</label>
            </td>
            <td>
                <input type="text" name="username" value="@JDM.String(Model.Username)" maxlength="100" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("AccountFlags").Name("Active"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" disabled value="Active" @(JDM.HasFlags(Model.Flags, "Active") ? "checked" : String.Empty) />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("AccountFlags").Name("Verified"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" disabled value="Verified" @(JDM.HasFlags(Model.Flags, "Verified") ? "checked" : String.Empty) />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>